document.querySelector('.btn').addEventListener('click', function (e) {
  const form = document.querySelector('.login-form')
  const formSTR = serialize(form, { hash: true, empty: true })
  // console.log(formSTR);
  // 登录
  if (formSTR.mobile.length !==11){
myAlert(false,"手机号码要11位数")
return
}
  if (formSTR.code.length !== 6){
myAlert(false,"验证码长度要6位数")
return
}
  axios({
    url: "/v1_0/authorizations",
    method: 'POST',
    data: formSTR
  }).then(result => {
    myAlert(true, '登录成功')
    // 登录成功跳转并保存token
    localStorage.setItem('token', result.data.data.token)
    // 延迟跳转，让警告框延迟一会
    setTimeout(() => {
      location.href = '../content/content.html'
    }, 2000)

  }).catch(err => {
    myAlert('false', err.response.data.message)
  })
})


